import ajax from "@/app/ajax";

export default {
  //主页
  home: {
    //根据编码查询内容
    findContentByCode(code) {
      return this.findContentDicList().then(d => {
        let item = d.find(i => i.code == code);
        return item ? item.contents : '';
      });
    },
    //查询内容字典列表
    findContentDicList() {
      return ajax.postCacheData("contentDicList", "/api/home/findContentDicList")
    }
  },
  //文章
  article: {
    //查询文章分类列表
    findArticleCategoryList() {
      return ajax.postCacheData("articleCategoryList", "/api/articleCategory/findList")
    },
    //查询文章分页列表
    findArticlePageList(ops) {
      let data = Object.assign({
        categoryId: '',
        isSlide: -1,
        isIndex: -1,
        isYao: -1,
        status: 1,
        pageIndex: 1,
        pageSize: 10,
        sortName: 'CreateTime',
        sortDir: 'desc'
      }, ops);
      return ajax.post('/api/article/findPageList', data);
    },
    //查询文章详细信息
    findArticleById(id) {
      return ajax.post('/api/article/findById', {id});
    },
    //查询要闻文章列表
    findYaoList(count = 8) {
      return ajax.postCacheData("articleYaoList", "/api/article/findYaoList", {count})
    },
    //查询幻灯片文章列表
    findSlideList(count = 8) {
      return ajax.postCacheData("articleSlideList", "/api/article/findSlideList", {count})
    }
  },
  //失物招领
  lostFound: {
    findPageList(pageIndex, pageSize) {
      return ajax.post('/api/lostFound/findPageList', {pageIndex, pageSize});
    }
  },
  //友情链接
  webLink: {
    //查询友情链接列表
    findList() {
      return ajax.postCacheData("webLinkList", '/api/webLink/findList');
    }
  },
  //旅游景点
  tour: {
    //查询旅游景点列表
    findTourList() {
      return ajax.postCacheData("tourList", '/api/tour/findTourList');
    },
    //查询首页旅游景点列表
    findHomeTourList(count = 8) {
      return ajax.postCacheData("homeTourList", '/api/tour/findHomeTourList', {count});
    }
  }
}